package remoto;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.Naming;

public class BD {
	
	IGestion gestion;
	private static BD instance;
	
	private BD() throws UnknownHostException {
		this.LookupService(InetAddress.getLocalHost().getHostAddress());
	}
	
	public static BD getInstance() throws UnknownHostException {
		if (instance == null) {
			instance = new BD(); 
		}
		return instance;
	}
	
	public void LookupService(String uri) {
        try {
                String vinculo = "//".concat(uri.trim().concat("/Gestion"));
                        gestion = (IGestion)Naming.lookup (vinculo);
                        System.out.println(vinculo);
                } catch (Exception e) {
                        javax.swing.JOptionPane.showMessageDialog(null, e.getMessage());
                } 
    }
	
	public IGestion getGestion() {
		return gestion;
	}

}
